package com.top.service;

import com.top.em.MenuEnum;
import com.top.em.TipEnum;
import com.top.utils.SoutUtil;
import sun.text.resources.cldr.ti.FormatData_ti_ER;

import java.util.Scanner;

/**
 * @Author:
 * @DateTime: 2023/12/8 22:33
 * @Description: TODO
 */
public class CommonService {
    private CategoryFoodService categoryFoodService = new CategoryFoodService();
    private FoodService foodService = new FoodService();
    private OrderService orderService = new OrderService();

    public void index() {
        Scanner scanner = new Scanner(System.in);
        System.out.println(TipEnum.COMMON.getTip());
        SoutUtil.printButton(MenuEnum.CATEGORY_FOOD, MenuEnum.FOOD, MenuEnum.ORDER_LIST);
        String next = scanner.next();
        if (next.startsWith(MenuEnum.CATEGORY_FOOD.getCode())) {
            categoryFoodService.index();
        } else if (next.startsWith(MenuEnum.FOOD.getCode())) {
            foodService.index();
        } else if (next.startsWith(MenuEnum.ORDER_LIST.getCode())) {
            orderService.index();
        } else if (next.startsWith(MenuEnum.QUIT.getCode())) {
            System.out.println("退出登录");
            System.exit(0);
        } else {
            System.err.println("输入错误");
            index();
        }

    }
}
